<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
  </head>

  <body>
    <p id="decimals">From $0,00 to $5,00</p>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script src="./9/jquery.animateNumber.min.js"></script>
    <script>
      // how many decimal places allows
      var decimal_places = 2
      var decimal_factor = decimal_places === 0 ? 1 : Math.pow(10, decimal_places) // 阶乘 10^2 === 100

      $('#decimals').animateNumber(
        {
          number: 5 * decimal_factor,

          numberStep: function (now, tween) {
            var floored_number = Math.floor(now) / decimal_factor,
              target = $(tween.elem)

            if (decimal_places > 0) {
              // force decimal places even if they are 0
              floored_number = floored_number.toFixed(decimal_places)

              // replace '.' separator with ','
              floored_number = floored_number.toString().replace(',', '.')
            }

            target.text('$' + floored_number)
          },
        },
        2000
      )
    </script>
  </body>
</html>
